package com.hundsun.documentripper.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hundsun.documentripper.domain.pojo.NodeContent;
import com.hundsun.documentripper.mapper.NodeContentMapper;
import com.hundsun.documentripper.service.NodeContentService;

/**
 * Note：
 *
 * @author ：mengjw
 * @description：节点内容接口实现
 * @date ：Created in 2021/2/1
 */
@Service
public class NodeContentServiceImpl implements NodeContentService {

    @Autowired
    private NodeContentMapper nodeContentMapper;

    @Override
    public void insertNodeContent(NodeContent nodeContent) {
        nodeContentMapper.insert(nodeContent);
    }

    @Override
    public void insertNodeContentBatch(List<NodeContent> nodeContentList) {
        nodeContentMapper.insertBatchSomeColumn(nodeContentList);
    }

    @Override
    // @Cacheable(cacheNames = {"nodeContent"})
    public NodeContent getNodeContent(String uuid) {
        return nodeContentMapper.selectById(uuid);
    }

    @Override
    public List<NodeContent> getNodeContentList(List<String> uuidList) {
        if (!uuidList.isEmpty()) {
            QueryWrapper<NodeContent> contentWrapper = new QueryWrapper<>();
            contentWrapper.in("uuid", uuidList);
            return nodeContentMapper.selectList(contentWrapper);
        }
        return new ArrayList<>();
    }

}
